package com.atguigu.spzx.user.controller;

import com.atguigu.spzx.model.entity.order.Region;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.user.service.RegionService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author LT
 * @create 2024-03-29-21:01
 */
@RestController
@RequestMapping("/api/user/region")
public class RegionController {

    @Resource
    RegionService regionService;

    @GetMapping("/findByParentCode/{parentCode}")
    public Result findByParentCode(@PathVariable("parentCode")Long parentCode){
        List<Region> regionList = regionService.list(Wrappers.lambdaQuery(Region.class)
                .eq(Region::getParentCode,parentCode));
        return Result.ok(regionList);
    }


}
